package edu.zut.operator;

/**
 * @fileName: OpertaorDemo
 * @author: xueyin
 * @data: 2021/3/1816:37
 * @description: 运算符
 */
public class OperatorDemo {


    public static void main(String[] args) {
//        一元运算符   -  ++   --
        int a = 89;
        int b = -a;//-89
//      ++自增1   --  自减1
//        a = a + 1;
        a++; //++a   90

//        ++ 在后  涉及赋值  先赋值  后运算
//        int c = a;
//        a = a +1;
        int c = a++;

        System.out.println("c:" + c);  // 90
        System.out.println("a:" + a); //91
//      1. a = a +1 ; 2. c = a;
        c = ++a;
        System.out.println("c:" + c);  // 92
        System.out.println("a:" + a); //92


//        二元运算符   +   -   *    /    %
//ArithmeticException: / by zero   算法异常
//        int d = a / 0;

        double d = a / 0.0;
        System.out.println("d = " + d);
//         /  如果涉及到小数  不再是取商
        d = a / 2.2;
        System.out.println(d);

        int score = 4600;
        int sum = 51;
        double newScore = score;
        double avg = newScore / sum;
        System.out.println("平均数" + avg);

//      算术赋值 ： +=  -=   *=  /=   %=     默认不支持short   byte
        int s = 78;
        s++;
//        s = s + 1;

//        s = s + 2;
        s += 2;
//        s = s - 3;
        s -= 3;
//        s = s * 3;
        s *= 3;





    }


}
